package me.xiaoyan.java.chapter12;

import java.util.Scanner;

public class ScoreCalc {
	//java成绩
	double javaScore;
	//c#成绩
	double charpScore;
	//db
	double dbScore;
	
	//计算总分
	public double sum()
	{
		return javaScore + charpScore + dbScore;
	}
	
	//计算平均分
	public double avg()
	{
		return sum() / 3;
	}
	
	/**
	 * 开始计算
	 * 输出计算结果
	 */
	public void startCalc(){
		System.out.println("总分:" + sum() 
				+ "  平均分:" + avg());
	}
	
	/**
	 * 开始执行程序
	 * @param args
	 */
	public static void main(String[] args) {
		ScoreCalc calc = new ScoreCalc();//创建计算分数的对象
		Scanner input = new Scanner(System.in);//创建输入对象
		//给成绩赋值
		System.out.println("请输入java成绩:");
		calc.javaScore = input.nextDouble();
		System.out.println("请输入C#成绩:");
		calc.charpScore = input.nextDouble();
		System.out.println("请输入DB成绩:");
		calc.dbScore = input.nextDouble();
		//开始计算成绩
		calc.startCalc();
	}
}